import React, {useEffect, useState} from 'react'
import {View,Text} from '@tarojs/components'
import store from "../../../store";
import EvaluationCon from './evaluationcon'

import './index.scss'

export default function MyEvaluation(){
  const [currEvaluationNav, useCurrEvaluationNav] = useState(store.getState().currEvaluationNav)
  useEffect(() => {
    store.subscribe(changeState)
  },[])

  function changeCurrEvaluationNav(index){
    const action = {
      type:'change_curr_evaluation_nav',
      index
    }
    store.dispatch(action)
  }
  function changeState(){
    useCurrEvaluationNav(store.getState().currEvaluationNav)
  }
  return (
    <View className='my_evaluation'>
      {/*evaluationNav*/}
      <View className='evaluation_nav'>
        <Text
          className={`evaluation_nav_item ${currEvaluationNav === 0? 'is_evaluation_nav' : ''}`}
          onClick={() => {changeCurrEvaluationNav(0)}}
        >待评价</Text>
        <Text
          className={`evaluation_nav_item ${currEvaluationNav === 1? 'is_evaluation_nav' : ''}`}
          onClick={() => {changeCurrEvaluationNav(1)}}
        >已评价</Text>
      </View>
      {/*内容*/}
      <View className='evaluation_con'>
        <EvaluationCon />
      </View>
    </View>
  )
}
